package com.group.aliyun.dao.dataobject;

import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.Data;

import java.util.HashMap;
import java.util.Map;

/**
 * @author <a href="mailto:chenxilzx1@gmail.com">theonefx</a>
 */
@Data
public class UserDO {
    private Long id;

    private String name;

    private Integer age;

    public static void main(String[] args) {
        String jsonStr = "{\"query\":{\"bool\":{\"must\":[{\"bool\":{\"must\":[{\"term\":{\"1_10\":\"1\"}}],\"should\":[]}}],\"should\":[]}}}";
        JSONObject jsonObject = JSONUtil.parseObj(jsonStr);
        Object o = jsonObject.get("query");


        System.out.println(o.toString());

        String j = "{\"bool\": {\"must\": [{\"term\": {\"ismobilelatest_cenum\": {\"value\": \"1\"}}}]}}";

        JSONObject jObject = JSONUtil.parseObj(j);

        Object bo = jObject.get("bool");
        System.out.println(bo.toString());

        UserDO u = new UserDO();
        u.setId(1L);
        u.setName("名字");
        u.setAge(18);

        JSONObject json = JSONUtil.parseObj(u, false);
        System.out.println(json);
        Map m = new HashMap();
        //{"name":"名字","id":1,"age":18}
        m.put("id", 1L);
        m.put("name", "名字");
        m.put("age", 18);
        JSONObject s = JSONUtil.parseObj(m, false);
        System.out.println(s);

        Map query = new HashMap();
        Map bool = new HashMap();
        query.put("query", bool);



    }
}
